from machine import Pin
import time
import ds1302
from machine import RTC
import jhx_ws2812b as jws

rtc = RTC()
# rtc.datetime((2017, 8, 23, 1, 12, 48, 0, 0)) # set a specific date and time
# rtc.datetime() # get date and time

ds = ds1302.DS1302(Pin(5),Pin(18),Pin(19))

# ds.date_time() # returns the current datetime.

rtcDate = ()
rtc.datetime((ds.year(), ds.month(), ds.day(), ds.weekday(), ds.hour(), ds.minute(), ds.second(), 0))

# while True:
#     # print('now: ' + str(ds.year()) + '-' + str(ds.month()) + '-' + 
#     # str(ds.day()) + ' ' + str(ds.hour()) + ':' + str(ds.minute()) + ':' + str(ds.second()))
#     print('ds1302: ' + str(ds.year()) + '-' + str(ds.month()) + '-' + 
#     str(ds.day()) + ' ' + str(ds.hour()) + ':' + str(ds.minute()) + ':' + str(ds.second()))
#     print(ds.weekday())
#     print('rtc: ' + str(rtc.datetime()))
#     time.sleep(1)
sourceArr = [[[0, 0, 0]] * 32 for i in range(8)]

jws.cleanScreen(sourceArr, np)
jws.showPattern(sourceArr, np, 'wifi', [0, 6], [30,144,255], 1)
# jws.showPattern(sourceArr, np, 'wifi-waiting', [0, 20], [30,144,255], 1)
# jws.showPattern(sourceArr, np, 'wifi-connect', [0, 20], [0,255,0], 1)
# jws.showPattern(sourceArr, np, 'wifi-fail', [0, 20], [255,0,0], 1)
# jws.cleanScreen(sourceArr, np)


# dateStr = '10'+' '+'09'
# jws.strMapper(sourceArr, dateStr, [1, 8], [17, 48, 17])
# jws.charMapper(sourceArr, ':', [1, 16], [17, 48, 17])
# jws.arrConvert(sourceArr, np)
# np.write()